package com.t235.gc.order.service.impl;

import com.t235.gc.entity.GarbageRecyclingDetailOrder;
import com.t235.gc.dao.GarbageRecyclingDetailOrderDao;
import com.t235.gc.order.service.GarbageRecyclingDetailOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 垃圾回收详情订单表(GarbageRecyclingDetailOrder)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:29
 */
@Service("garbageRecyclingDetailOrderService")
public class GarbageRecyclingDetailOrderServiceImpl implements GarbageRecyclingDetailOrderService {
    @Resource
    private GarbageRecyclingDetailOrderDao garbageRecyclingDetailOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param detailorderid 主键
     * @return 实例对象
     */
    @Override
    public GarbageRecyclingDetailOrder queryById(Long detailorderid) {
        return this.garbageRecyclingDetailOrderDao.queryById(detailorderid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GarbageRecyclingDetailOrder> queryAllByLimit(int offset, int limit) {
        return this.garbageRecyclingDetailOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param garbageRecyclingDetailOrder 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageRecyclingDetailOrder insert(GarbageRecyclingDetailOrder garbageRecyclingDetailOrder) {
        this.garbageRecyclingDetailOrderDao.insert(garbageRecyclingDetailOrder);
        return garbageRecyclingDetailOrder;
    }

    /**
     * 修改数据
     *
     * @param garbageRecyclingDetailOrder 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageRecyclingDetailOrder update(GarbageRecyclingDetailOrder garbageRecyclingDetailOrder) {
        this.garbageRecyclingDetailOrderDao.update(garbageRecyclingDetailOrder);
        return this.queryById(garbageRecyclingDetailOrder.getDetailorderid());
    }

    /**
     * 通过主键删除数据
     *
     * @param detailorderid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long detailorderid) {
        return this.garbageRecyclingDetailOrderDao.deleteById(detailorderid) > 0;
    }
}
